//
//  CAMoneyTableHeaderView.m
//  LNH
//
//  Created by twentylx on 2018/1/22.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAMoneyTableHeaderView.h"

@implementation CAMoneyTableHeaderView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor whiteColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.inButton];
    [self addSubview:self.outButton];
    [self addSubview:self.titleLabel];
    [self addSubview:self.lineView];
}

#pragma mark layout
- (void) updateConstraints {
    [super updateConstraints];
    
    [_inButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self).offset(10);
        make.width.mas_equalTo(SCREEN_WIDTH/2 - 30);
        make.height.mas_equalTo(44);
    }];
    
    [_outButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-20);
        make.top.equalTo(self.inButton);
        make.width.mas_equalTo(SCREEN_WIDTH/2 - 30);
        make.height.mas_equalTo(44);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.outButton.mas_bottom).offset(20);
        make.centerX.equalTo(self);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.bottom.equalTo(self).offset(10);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
}

#pragma mark get & set
- (UIButton *) inButton {
    if (!_inButton) {
        _inButton = [UIButton new];
        _inButton.backgroundColor = RGBCOLOR(240, 90, 36);
        [_inButton setTitle:@"入账记录" forState:UIControlStateNormal];
        _inButton.titleLabel.font = [UIFont systemFontOfSize:22];
    }
    return _inButton;
}

- (UIButton *) outButton {
    if (!_outButton) {
        _outButton = [UIButton new];
        _outButton.backgroundColor = RGBCOLOR(203, 203, 203);
        [_outButton setTitle:@"提现记录" forState:UIControlStateNormal];
        _outButton.titleLabel.font = [UIFont systemFontOfSize:22];
    }
    return _outButton;
}

- (UILabel *) titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"收入明细";
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

- (UIView *) lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(51, 51, 51);
    }
    return _lineView;
}

@end
